local sk__chenyu = fk.CreateSkill {

  name = "sk__chenyu",

  tags = { Skill.Compulsory, },

}



sk__chenyu:addEffect(fk.EventPhaseStart, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(sk__chenyu.name) and #player.room.alive_players > 1 then
      return player.phase == Player.Finish
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = {}
    for _, p in ipairs(room:getOtherPlayers(player)) do
      table.insertTable(cards, table.filter(p:getCardIds("h"), function(id)
        return Fk:getCardById(id).suit == Card.Heart
      end))
    end
    if #cards > 0 then
      room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonPrey, sk__chenyu.name, nil, false, player)
    end
  end,
})
sk__chenyu:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(sk__chenyu.name) and #player.room.alive_players > 1 then
     return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = {}
    for _, p in ipairs(room:getOtherPlayers(player)) do
      table.insertTable(cards, table.filter(p:getCardIds("h"), function(id)
        return Fk:getCardById(id).suit == Card.Heart
      end))
    end
    if #cards > 0 then
      room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonPrey, sk__chenyu.name, nil, false, player)
    end
  end,
})

return sk__chenyu